package com.eims.sls_app.ui.adapter;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import bls.juejin.cn.R;

import com.eims.sls_app.dataaccess.FollowsBean;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class WithdetailsAdapter extends BaseAdapter {

	private List<FollowsBean> followsBeans;
	private Context context;
	
	
	
	
	public WithdetailsAdapter(List<FollowsBean> followsBeans, Context context) {
		super();
		this.followsBeans = followsBeans;
		this.context = context;
	}

	@Override
	public int getCount() {
		
		return followsBeans.size();
	}

	@Override
	public Object getItem(int position) {
		
		return position;
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		ViewHolder holder;
		if (view == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(context);
			// 得到布局文件
			view = inflater.inflate(R.layout.with_details_item, null);
			holder.tv_name = (TextView) view.findViewById(R.id.tv_details_name);
			holder.tv_jine = (TextView) view.findViewById(R.id.tv_details_jine);
			holder.tv_jinagjin = (TextView) view.findViewById(R.id.tv_details_jiangjin);
			holder.tv_yongjin = (TextView) view.findViewById(R.id.tv_details_yongjin);
			view.setTag(holder);
		}else {
			holder = (ViewHolder) view.getTag();
		}
		String name = followsBeans.get(position).Name;
		final String isname;
		if (isMobileNO(name)) {
			isname = name.substring(0, 3)+"****"+name.substring(7, name.length());
			//holder.tv_name.setText());
		}else {
			isname = name;
			//holder.tv_name.setText(name.substring(0, 2)+"**");
		}
		holder.tv_name.setText(isname);
		holder.tv_jine.setText(followsBeans.get(position).Money+"");
		if ((followsBeans.get(position).WinMoney+"").equals("0.0")) {
			holder.tv_jinagjin.setText("-");
		}else {
			holder.tv_jinagjin.setText(followsBeans.get(position).WinMoney+"");
		}
		
		if ((followsBeans.get(position).yj+"").equals("0.0")) {
			holder.tv_yongjin.setText("-");
		}else {
			holder.tv_yongjin.setText(followsBeans.get(position).yj+"");
		}
		
		//holder.tv_yongjin.setText(followsBeans.get(position).yj+"");
		return view;
	}
	
	static class ViewHolder {
		TextView tv_name;
		TextView tv_jine;
		TextView tv_jinagjin;
		TextView tv_yongjin;
	}
	
	 public boolean isMobileNO(String mobiles) {
		 Pattern p = Pattern.compile("1[0-9]{10}");
		 Matcher m = p.matcher(mobiles);
		 return m.matches();
		 }

}
